from django.conf import settings
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer  # 加密包
import RabbitMQ_tasks.send_email_MQ.base
from web import models

serializer = Serializer(settings.SECRET_KEY)
info = {'confirm': 22}
token = serializer.dumps(info)  # 加密是加密的这个字典，之后解码成utf8，就没有b'....'了，更好看一点
token = token.decode()
print(token)


info = serializer.loads(token)
# 获取待激活用户的id
user_id = info['confirm']
print(user_id)
# 根据id获取用户信息
user = models.UserInfo.objects.filter(id=user_id).first()
user.is_active = 1  # 激活成功
user.save()